package Hibernate.cn.edu.scau.cmi.lishuoxin.client;


import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

public class BasePane extends VBox{

	//编写基本的可重用的模块
	
	//添加模块
	protected HBox addBox;
	protected TextField addForId;
	protected TextField addForName;
	protected Button addButton;
	
	//修改模块
	protected HBox updateBox;
	protected TextField updateForId;
	protected TextField updateForName;
	protected Button updateButton;
	
	//删除模块
	protected HBox deleteBox;
	protected TextField deleteForId;
	protected TextField deleteForName;
	protected Button deleteButton;
	
	//展示模块
	protected HBox showBox;
	protected TextField showForId;
	protected TextField showForName;
	protected Button showButton;
	
	//选择模块
	protected HBox selectBox;
	protected TextField selectForId;
	protected TextField selectedForTutorId;
	protected Button selectButton;
	
	//修改
	protected HBox updateSelectBox;
	protected TextField updateSelectForId;
	protected TextField updateSelectForTutorId;
	protected Button updateSelectButton;
	
	private static int MARGIN = 20;
	
	public BasePane() {
		super(20);
	}
	
	protected void init() {
		addModel();
		updateModel();
		deleteModel();
		showModel();
		selectModel();
		updateSelectModel();
	}
	
	private void addModel() {
		addBox = new HBox(this.MARGIN);
		addForId = new TextField();
		addForId.setPromptText("Input Id");
		addForName = new TextField();
		addForName.setPromptText("Input Name");
		addButton = new Button("添加");
		addBox.getChildren().addAll(addForId,addForName,addButton);
		this.getChildren().add(addBox);
	}
	
	private void updateModel() {
		updateBox = new HBox(this.MARGIN);
		updateForId = new TextField();
		updateForId.setPromptText("Input Id");
		updateForName = new TextField();
		updateForName.setPromptText("Input Name");
		updateButton = new Button("更新");
		updateBox.getChildren().addAll(updateForId,updateForName,updateButton);
		this.getChildren().add(updateBox);
	}
	
	private void deleteModel() {
		deleteBox = new HBox(this.MARGIN);
		deleteForId = new TextField();
		deleteForId.setPromptText("Input Id");
		deleteForName = new TextField();
		deleteForName.setPromptText("Input Name");
		deleteButton = new Button("删除");
		deleteBox.getChildren().addAll(deleteForId,deleteForName,deleteButton);
		this.getChildren().add(deleteBox);
	}
	
	private void showModel() {
		showBox = new HBox(this.MARGIN);
		showForId = new TextField();
		showForId.setPromptText("Input Id");
		showForName = new TextField();
		showForName.setPromptText("Input Name");
		showButton = new Button("查找");
		showBox.getChildren().addAll(showForId,showForName,showButton);
		this.getChildren().add(showBox);
	}
	
	private void selectModel() {
		selectBox = new HBox(this.MARGIN);
		selectForId = new TextField();
		selectForId.setPromptText("Input Student Id");
		selectedForTutorId = new TextField();
		selectedForTutorId.setPromptText("Input Teacher Id");
		selectButton = new Button("选择");
		selectBox.getChildren().addAll(selectForId,selectedForTutorId,selectButton);
		this.getChildren().add(selectBox);
	}
	
	private void updateSelectModel() {
		updateSelectBox = new HBox(this.MARGIN);
		updateSelectForId = new TextField();
		updateSelectForId.setPromptText("Input Student Id");
		updateSelectForTutorId = new TextField();
		updateSelectForTutorId.setPromptText("Input Teacher Id");
		updateSelectButton = new Button("更新选择");
		updateSelectBox.getChildren().addAll(updateSelectForId,updateSelectForTutorId,updateSelectButton);
		this.getChildren().add(updateSelectBox);
	}
}
